#include <iostream>

using namespace std;

int main(){
    int n, x;
    int tmp;
    int ans = 0;
    cin >> n >> x;
    for(int i = 1; i <= n; i++){
        tmp = i;
        while(tmp){
            int m;
            m = tmp % 10;
            tmp /= 10;
            if(m == x) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}